package com.scn.base.dao.impl;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;

import org.springframework.orm.ibatis.support.SqlMapClientDaoSupport;

import com.scn.base.dao.SysUserDao;
import com.scn.base.domain.UserVO;
import com.scn.base.page.PageVO;

public class SysUserDaoImpl extends SqlMapClientDaoSupport implements SysUserDao{
	public UserVO selectUserByNo(String userno) {
		Object temp = getSqlMapClientTemplate().queryForObject("selectUserByNo",userno);
		if(temp==null){
			return null;
		}else{
			return (UserVO)temp;
		}
	}
	public List<UserVO> selectUserListByRole(Integer userrole) {
		List<UserVO> userList = getSqlMapClientTemplate().queryForList("selectUserListByRole",userrole);
		return userList;
	}
	public void updateUserStatus(UserVO user) {
		getSqlMapClientTemplate().update("updateUserStatus", user);
	}
//	public List selectUserList() {   
//		 
//		return getSqlMapClientTemplate().queryForList("selectUserList");
//	}
	public int selectUserListCount() {
		return (Integer)getSqlMapClientTemplate().queryForObject("selectUserListCount");
	}
	
	
	public List<UserVO> selectUserList(PageVO page) {
		List list = new ArrayList();
		list = getSqlMapClientTemplate().queryForList("selectUserList",(page.getCurPage()-1)*page.getPageSize(), page.getPageSize());
		if(list != null && list.size() > 0){
			return list;
		}else{
		    return null;
		}
	}
	public void deleteUserById(int userid) {
		getSqlMapClientTemplate().delete("deleteUserById",userid);
	}
	public UserVO selectUserById(int userid) {
		Object temp = getSqlMapClientTemplate().queryForObject("selectUser",userid);
		if(temp==null){
			return null;
		}else{
			return (UserVO)temp;
		}
		//return (UserVO)getSqlMapClientTemplate().queryForObject("selectUser",userid);
	}
	public void updateUser(Map userMap) {
		getSqlMapClientTemplate().update("updateUser",userMap);
	}
	public long selectUserSeq() {
		return (Long)getSqlMapClientTemplate().queryForObject("selectUserSeq");
	}
	public void insertUser(UserVO userVo) {
		 getSqlMapClientTemplate().insert("insertUser",userVo);
	}
	public void initPwd(Map initPwdMap) {
		getSqlMapClientTemplate().update("initPwd",initPwdMap);
	}
	public void updatePwd(Map pwdMap) {
		getSqlMapClientTemplate().update("updatePwd",pwdMap);
	}

}
